package com.zwps.common.controller.response.message;

import com.zwps.common.core.exception.status.CommonExceptionStatus;
import com.zwps.extra.http.response.message.DefaultResponseMessage;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

@Schema(description = "响应基础结构")
@Getter
public class ResponseMessage extends DefaultResponseMessage {

    @Schema(description = "处理结果")
    private boolean success;

    @Schema(description = "处理结果状态码")
    @Override
    public Integer getCode() {
        return super.getCode();
    }
    
    @Schema(description = "处理结果消息")
    @Override
    public String getMessage() {
        return super.getMessage();
    }
    
    public ResponseMessage() {
    }

    public ResponseMessage(Integer code, String message) {
        super(code, message);
    }

    public ResponseMessage(Integer code, String message, boolean success) {
        super(code, message);
        this.success = success;
    }

    public static ResponseMessage serverExceptionMessage() {
        CommonExceptionStatus status = CommonExceptionStatus.SERVE_ERROR;
        return new ResponseMessage(status.getCode(), status.getDescribe());
    }

    public static ResponseMessage successMessage() {
        CommonExceptionStatus status = CommonExceptionStatus.USER_ACTION_SUCCESS;
        return new ResponseMessage(status.getCode(), status.getDescribe(), true);
    }

    public static ResponseMessage authenticationFailureMessage(String message) {
        CommonExceptionStatus status = CommonExceptionStatus.AUTHENTICATION_FAILURE;
        return new ResponseMessage(status.getCode(), message);
    }

    public static ResponseMessage parameterErrorMessage(String message) {
        CommonExceptionStatus status = CommonExceptionStatus.PARAMETER_ERROR;
        return new ResponseMessage(status.getCode(), message);
    }

    public static ResponseMessage parameterErrorMessage() {
        CommonExceptionStatus status = CommonExceptionStatus.PARAMETER_ERROR;
        return new ResponseMessage(status.getCode(), status.getDescribe());
    }
    
    public static ResponseMessage fileSizeExceedsMaximumLimitMessage() {
        CommonExceptionStatus status = CommonExceptionStatus.FILE_SIZE_EXCEEDS_MAXIMUM_LIMIT;
        return new ResponseMessage(status.getCode(), status.getDescribe());
    }

}
